package q3;

import java.io.*;
import java.util.StringTokenizer;

public class ReadFile {
	
	public boolean[][] matrix;
	public int size;
	public int max;
	
	public ReadFile(){
		
	}

	public void openFile(String filename){
		try {
			File f = new File(filename);
			BufferedReader input =  new BufferedReader(new FileReader(f));
			String line = null; 
			int edges = 0; 
			while (( line = input.readLine()) != null){
				if(line.startsWith("p")){
					StringTokenizer st = new StringTokenizer(line);
					while (st.hasMoreTokens()) {
					   if(st.nextToken().equals("edge")){
						   size = Integer.parseInt(st.nextToken());
						   edges = Integer.parseInt(st.nextToken());
						   matrix = new boolean[size][size];
					   }
					} 
				}
				else if(line.startsWith("e")){
					StringTokenizer st = new StringTokenizer(line);
					while (st.hasMoreTokens()) {
					   if(st.nextToken().equals("e")){
						   int source = Integer.parseInt(st.nextToken());
						   int sink = Integer.parseInt(st.nextToken());
						   matrix[source-1][sink-1]=true;
						   matrix[sink-1][source-1]=true;
					   }
					} 
				}
//				System.out.println(line);
			}
			max = (int)((1+ Math.sqrt(1+(8*(double)edges)))/2);
//			f.delete();
//			f.createNewFile();
//			for(int i=0; i<30; i++){
//				for(int j=0; j<30; j++){
//					if(matrix[i][j])
//						System.out.print("1");
//					else System.out.print("0");
//				}
//				System.out.println();
//			}
		}catch (Exception e) {
		}
	}
//
//	public static void main(String[] args) {
//		ReadFile rf = new ReadFile();
//		rf.openFile("c-fat500-1.txt");
//	}
}
